var ViewNavigator = require('utils/ViewNavigator');

var FACEBOOK_APP_ID = '1438403633094256';
var FACEBOOK_CLIENT_SECRET = '3b69bcae4bac1e58b4a2dbba41a22563';
var FACEBOOK_APP_PERMISSIONS = ['publish_actions', 'user_friends'];

var fb = Alloy.Globals.Facebook;
fb.appid = FACEBOOK_APP_ID;
fb.permissions = FACEBOOK_APP_PERMISSIONS;
$.fbButton.style = fb.BUTTON_STYLE_WIDE;


fb.addEventListener('login', function(e) {
    if (e.success) {
    	//TODO: extendLoginProdeByFacebook();
    	navigateHome();
    } else {
    	alert(L('error_login_facebook'));
    }
});

$.index.open();

if(fb.getLoggedIn()){
	navigateHome();
}

function navigateHome() {
	ViewNavigator.navigateToView("Home");
}

